Skip to content

Re-enable relative paths for std links in rustc-docs#153162

Open
arferreira wants to merge 1 commit intorust-lang:mainfrom
arferreira:re-enable-relative-std-links
Open

Re-enable relative paths for std links in rustc-docs#153162
arferreira wants to merge 1 commit intorust-lang:mainfrom
arferreira:re-enable-relative-std-links

Conversation

@arferreira
Copy link
Contributor

@arferreira arferreira commented Feb 27, 2026

Closes #151496.

PR #152243 added --extern-html-root-url core=../ so rustc-docs would link to local std docs for offline usage. It caused #152917 because ../ was the wrong depth — at depth 2+ pages the links resolved inside the compiler docs tree instead of reaching the std docs. #152976 reverted it.

From rustc-docs/rustc_middle/index.html, ../../core/ reaches html/core/. The published layout on doc.rust-lang.org works the same way (nightly/nightly-rustc/../../nightly/).

Rustdoc's remote_url_prefix (#152977) handles deeper module pages by adding extra ../ segments automatically. Source pages get correct depth via remote_item_depth (#153160).

r? @GuillaumeGomez

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 27, 2026
@GuillaumeGomez
Copy link
Member

Looks good to me, thanks! For now, blocked on #153160.

@GuillaumeGomez GuillaumeGomez added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Feb 27, 2026
Comment on lines +956 to +959
// Link std crates to local docs. Installed layout:
// html/ <- std docs (core/, std/, alloc/, ...)
// html/rustc-docs/ <- compiler docs
// `../../` from rustc-docs/*/index.html reaches html/.
Copy link
Contributor

@eggyal eggyal Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be the installed layout, but if someone simply does ./x doc and browses the documentation in their build/doc directory, I guess these relative links won't work? Is that a use case we care about? Perhaps we could change the layout in the build directory to be consistent with the "installed" layout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right, but changing the build layout to match would be a larger change and might break other assumptions, I mean could be nice but feels like a separate effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local rustc-docs could make use of local pages for std types

4 participants